﻿
#include <iostream>
#include "../../win_com/xx_com.hpp"
#include "../../win_com/xx_remotethread_inject.hpp"
#include "../../win_com/xx_process.hpp"




int main(int argc, char** argv)
{
    //LoadLibraryA(R"(E:\code\code\tools\dll_inject\x64\Release\dll.dll)");
    auto dll_path = xx_get_arg(argc, argv, "-dll_path");
    if (dll_path) {
        printf("-dll_path=%s\n", dll_path);
    }

    auto pid = xx_get_arg(argc, argv, "-pid");
    if (pid) {
        printf("-pid=%s\n", pid);
        remotethread_inject(atoi(pid), dll_path);
    }

    auto pro_name = xx_get_arg(argc, argv, "-pro_name");
    if (pro_name) {
        while (1) {
            bool inject_ret = remotethread_inject2(pro_name, dll_path);

            printf("name=%s,ret=%d\n", pro_name, inject_ret);
            if (!inject_ret) {
                sleep_ns(100*1000*100);
                continue;
            }
            else {
                printf("ok!\n");
                break;
            }
        }

    }
    

    return 0;
}


